pdf <- function(x) {exp(-x)}
curve(pdf, from = 0, to=100, n=1000)
pdf <- function(x) {exp(-x)}
curve(pdf, from = 0, to=10, n=1000)
pdf <- function(x) {exp(-x)}
curve(pdf, from = 0, to=0.01, n=1000)
pdf <- function(x) {exp(-x)}
curve(pdf, from = 0, to=10, n=1000)
pdf <- function(x) {exp(-x)}
curve(pdf, from = 0, to=6, n=1000)
cdf <- function(x) {-exp(-x)}
curve(cdf, from = 0, to=6, n=1000)
cdf <- function(x) {-exp(-x) + 1}
curve(cdf, from = 0, to=6, n=1000)
pdf <- function(x) {exp(-x)}
curve(pdf, from = 0, to=6, n=1000)
pdf2 <- function(x) {(2/3)x^(-1/3)}  # for 0 <= x <= 1
curve(pdf1, from = 0, to=1, n=1000)
pdf2 <- function(x) {(2/3)x^(-1/3)}  # for 0 <= x <= 1
curve(pdf2, from = 0, to=1, n=1000)
pdf2 <- function(x) {(2/3)*(x^(-1/3))}  # for 0 <= x <= 1
curve(pdf2, from = 0, to=1, n=1000)
cdf2 <- function(x) {x^(2/3)}
curve(cdf2, from = 0, to=1, n=1000)
pdf2 <- function(x) {(2/3)*(x^(-1/3))}  # for 0 <= x <= 1
curve(pdf2, from = 0, to=1, n=1000)
cdf2 <- function(x) {x^(2/3)}
curve(cdf2, from = 0, to=1, n=1000)
pi
npdf <-function(x, mu, sigma) {
((2*pi*sigma^2)^(1/2))exp(-((x-mu)^2)/(2*sigma^2))
}
npdf <-function(x, mu, sigma) {
((2*3.14159*sigma^2)^(1/2))exp(-((x-mu)^2)/(2*sigma^2))
}
npdf <-function(x, mu, sigma) {
((2*pi*sigma^2)^(1/2))*exp(-((x-mu)^2)/(2*sigma^2))
}
npdf <-function(x) {
((2*pi*sigma^2)^(1/2))*exp(-((x-mu)^2)/(2*sigma^2))
}
mu<-0
sigma<-1
curve(npdf, from = -3, to=3, n=1000)
dnorm(0)
x<-(seq(-3,3,length.out=1000))
y<-(seq(0,1,length.out=1000))
plot(x,y, type = "n", main=paste("Prior and Posterior Distributions"), xlab=("θ"), ylab=("density"))
lines((seq(-3,3,length.out=1000)), dnorm(seq(-3,3,length.out=1000)), type="l", lwd=3, col="steelblue")
plot(x,y, type = "n", main=paste("Prior and Posterior Distributions"), xlab=("θ"), ylab=("density"))
lines((seq(-3,3,length.out=1000)), dnorm(seq(-3,3,length.out=1000)), type="2", lwd=1, col="steelblue")
plot(x,y, type = "n", main=paste("Prior and Posterior Distributions"), xlab=("θ"), ylab=("density"))
lines((seq(-3,3,length.out=1000)), dnorm(seq(-3,3,length.out=1000)), type="l", lwd=1, lty=1, col="steelblue")
lines((seq(-3,3,length.out=1000)), dnorm(seq(-3,3,length.out=1000), mean=1, sd=0.3), type="l", lwd=1, lty=2, col="maroon")
# plot normal curves on one figure
x<-(seq(-3,3,length.out=1000))
y<-(seq(0,1.4,length.out=1000))
plot(x,y, type = "n", main=paste("Prior and Posterior Distributions"), xlab=("θ"), ylab=("density"))
lines((seq(-3,3,length.out=1000)), dnorm(seq(-3,3,length.out=1000)), type="l", lwd=1, lty=1, col="steelblue")
lines((seq(-3,3,length.out=1000)), dnorm(seq(-3,3,length.out=1000), mean=1, sd=0.3), type="l", lwd=1, lty=2, col="maroon")
x<-(seq(-3,3,length.out=1000))
y<-(seq(0,1.4,length.out=1000))
plot(x,y, type = "n", main=paste("Prior and Posterior Distributions"), xlab=("θ"), ylab=("density"))
lines((seq(-3,3,length.out=1000)), dnorm(seq(-3,3,length.out=1000), mean=0, sd=10), type="l", lwd=1, lty=1, col="steelblue")
lines((seq(-3,3,length.out=1000)), dnorm(seq(-3,3,length.out=1000), mean=1, sd=0.1), type="l", lwd=1, lty=2, col="maroon")
x<-(seq(-3,3,length.out=1000))
y<-(seq(0,1.4,length.out=1000))
plot(x,y, type = "n", main=paste("Prior and Posterior Distributions"), xlab=("θ"), ylab=("density"))
lines((seq(-3,3,length.out=1000)), dnorm(seq(-3,3,length.out=1000), mean=0, sd=2), type="l", lwd=1, lty=1, col="steelblue")
lines((seq(-3,3,length.out=1000)), dnorm(seq(-3,3,length.out=1000), mean=1, sd=0.3), type="l", lwd=1, lty=2, col="maroon")
x<-(seq(-3,3,length.out=1000))
y<-(seq(0,1.4,length.out=1000))
plot(x,y, type = "n", main=paste("Prior and Posterior Distributions"), xlab=("θ"), ylab=("density"))
lines((seq(-3,3,length.out=1000)), dnorm(seq(-3,3,length.out=1000), mean=0.5, sd=0.3), type="l", lwd=1, lty=1, col="maroon")
d<-density(dnorm(seq(-3,3,length.out=1000), kernel="gaussian"))
polygon(c(0, rev(d$x[d$x<0])), c(0, rev(d$y[d$x<0])), col="maroon", border=NA)
d<-density(dnorm(seq(-3,3,length.out=1000))) #, kernel="gaussian"))
polygon(c(0, rev(d$x[d$x<0])), c(0, rev(d$y[d$x<0])), col="maroon", border=NA)
plot(x,y, type = "n", main=paste("Prior and Posterior Distributions"), xlab=("θ"), ylab=("density"))
lines((seq(-3,3,length.out=1000)), dnorm(seq(-3,3,length.out=1000), mean=0.5, sd=0.3), type="l", lwd=1, lty=1, col="maroon")
cord.x <- c(-3,seq(-3,0,0.01),0)
cord.y <- c(0,dnorm(seq(-3,0,0.01)),0)
polygon(cord.x,cord.y,col="maroon")
plot(x,y, type = "n", main=paste("Prior and Posterior Distributions"), xlab=("θ"), ylab=("density"))
lines((seq(-3,3,length.out=1000)), dnorm(seq(-3,3,length.out=1000), mean=0.5, sd=0.3), type="l", lwd=1, lty=1, col="maroon")
cord.x <- c(-3,seq(-3,0,0.01),0)
cord.y <- c(0,dnorm(seq(-3,0,0.01), mean=0.5, sd=0.3),0)
polygon(cord.x,cord.y,col="maroon")
# prior-posterior example
plot(x,y, type = "n", main=paste("Prior and Posterior Distributions"), xlab=("θ"), ylab=("density"))
lines((seq(-3,3,length.out=1000)), dnorm(seq(-3,3,length.out=1000), mean=0, sd=2), type="l", lwd=1, lty=2, col="steelblue")
lines((seq(-3,3,length.out=1000)), dnorm(seq(-3,3,length.out=1000), mean=1, sd=0.3), type="l", lwd=1, lty=1, col="maroon")
x<-(seq(-3,3,length.out=1000))
y<-(seq(0,1.4,length.out=1000))
plot(x,y, type = "n", main=paste("Prior and Posterior Distributions"), xlab=("θ"), ylab=("density"))
lines((seq(-3,3,length.out=1000)), dnorm(seq(-3,3,length.out=1000), mean=0.5, sd=0.3), type="l", lwd=1, lty=1, col="maroon")
cord.x <- c(-3,seq(-3,0,0.01),0)
cord.y <- c(0,dnorm(seq(-3,0,0.01), mean=0.5, sd=0.3),0)
polygon(cord.x,cord.y,col="maroon")
# prior-posterior example
plot(x,y, type = "n", main=paste("Prior and Posterior Distributions"), xlab=("θ"), ylab=("density"))
lines((seq(-3,3,length.out=1000)), dnorm(seq(-3,3,length.out=1000), mean=0, sd=2), type="l", lwd=1, lty=2, col="steelblue")
lines((seq(-3,3,length.out=1000)), dnorm(seq(-3,3,length.out=1000), mean=1, sd=0.3), type="l", lwd=1, lty=1, col="maroon")
setwd("C:/Users/Kevin/Dropbox/UCR/research/bayes/funglee/persuasion/OBOE/Replication/ResultsInPaper/Tutorial/basic_examples/linear")
